﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DAL
{  //对于评论相关的数据操作类
    public class CommentData
    {
        //获取用户输入的电影短评论的详细情况
        public void GetShortComment(int u_id, int m_id, string title, DateTime time, string details)
        {
            CommentsOfMovies scm = new CommentsOfMovies();
            scm.u_id = u_id;
            scm.m_id = m_id;
            scm.title = title;
            scm.time = time;
            scm.comment = details;
        }
        //获取用户输入的电影长评论
        public void GetLongComment(int u_id, int m_id, string title, DateTime time, string details)
        {
            CommentsOfMovies lcm = new CommentsOfMovies();
            lcm.u_id = u_id;
            lcm.m_id = m_id;
            lcm.title = title;
            lcm.time = time;
            lcm.comment = details;
        }
        //获取用户输入的电影院评论
        public void GetMovieComment(int u_id, int c_id, string title, DateTime time, string details)
        {
            CommentsOfCinemas cm = new CommentsOfCinemas();
            cm.u_id = u_id;
            cm.c_id = c_id;
            cm.title = title;
            cm.time = time;
            cm.comment = details;
        }
        //删除电影评论
        public void MovieDel(int id)
        {
            CommentsOfMovies cmm = new CommentsOfMovies();
            //将id值赋值给实体对象的u_mid属性 
            cmm.c_mid = id;
            ProjectDBEntities context = new ProjectDBEntities();
            context.CommentsOfMovies.Attach(cmm);
            //调用上下文对象的对象管理器改变上下文中要删除的实体对象的状态->已删除
            context.ObjectStateManager.ChangeObjectState(cmm, System.Data.EntityState.Deleted);
            context.SaveChanges();
        }
        //删除电影院评论
        public void CinemaDel(int id)
        {
            CommentsOfCinemas cmm = new CommentsOfCinemas();
            //将id值赋值给实体对象的u_cid属性 
            cmm.c_cid = id;
            ProjectDBEntities context = new ProjectDBEntities();
            context.CommentsOfCinemas.Attach(cmm);
            //调用上下文对象的对象管理器改变上下文中要删除的实体对象的状态->已删除
            context.ObjectStateManager.ChangeObjectState(cmm, System.Data.EntityState.Deleted);
            context.SaveChanges();
        }
<<<<<<< .mine

        public  IQueryable<CommentsOfMovies> Show(int u_id)
        {
            ProjectDBEntities efContext = new ProjectDBEntities();
            var list = from c in efContext.CommentsOfMovies where c.u_id == u_id select c;
            return list;
        }
=======
        public IQueryable<CommentsOfMovies> SC()
        {
            //  ////创建上下文对象，用来操作数据库
            ProjectDBEntities pde = new ProjectDBEntities();
            //在Movies中查询查询MovieLists表中对应的当前电影id的电影集合，返回该集合列表
            var m = from v in pde.CommentsOfMovies
                    select v;
            return m;           
        }
>>>>>>> .r63
    }
}

